package chances.system.operator.repo;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import chances.system.operator.entity.Organization;

public interface OrganizationRepository extends JpaRepository<Organization,Long> {
	
	@Query("from Organization where status = 0")
	public List<Organization> findAvaliableOrganization();
	
	@Modifying
	@Transactional
	@Query("delete Organization o where o.orgId = :orgId")
	public int deleteById(@Param("orgId") Long orgId);
	
	@Query("select o from Organization o")
	public Page<Organization> filter(@Param("parentId")Long parentId, Pageable pageable);
}
